package com.jet.member.gate;

import com.jet.core.result.ResultJson;
import com.jet.member.domain.vo.MemberInfoVo;
import com.jet.member.domain.vo.MemberListVo;
import com.jet.member.service.IMemberService;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/gate/member")
public class GateMemberController {

    private final IMemberService memberService;

    public GateMemberController(IMemberService memberService) {
        this.memberService = memberService;
    }

    @GetMapping("/list")
    public ResultJson<List<MemberListVo>> memberList(@RequestHeader long merchantNo,
                                                     @RequestHeader long storeNo,
                                                     @RequestHeader String accountId) {
        return ResultJson.ok(memberService.findAll(merchantNo));
    }

    @GetMapping("/search")
    public ResultJson<List<MemberListVo>> memberSearch(@RequestHeader long merchantNo,
                                                       @RequestHeader long storeNo,
                                                       @RequestHeader String accountId,
                                                       @RequestParam String searchKey) {
        List<MemberListVo> members = memberService.memberSearch(merchantNo, searchKey);
        return ResultJson.ok(members);
    }
}